def prost(c):
    if c == 1:
        return False
    for i in range(2, int(c ** 0.5) + 1):
        if c % i == 0:
            return False
    return True

a = str(input()).split()
c = ''
if a[0] == 'zero' or a[0] == 'one' or a[0] == 'two' or a[0] == 'three' or a[0] == 'four' or a[0] == 'five' or a[0] == 'six' or a[0] == 'seven' or a[0] == 'eight' or a[0] == 'nine':
    if  a[1] == 'zero' or a[1] == 'one' or a[1] == 'two' or a[1] == 'three' or a[1] == 'four' or a[1] == 'five' or a[1] == 'six' or a[1] == 'seven' or a[1] == 'eight' or a[1] == 'nine':
        if  a[2] == 'zero' or a[2] == 'one' or a[2] == 'two' or a[2] == 'three' or a[2] == 'four' or a[2] == 'five' or a[2] == 'six' or a[2] == 'seven' or a[2] == 'eight' or a[2] == 'nine':
            if a[0] == 'zero':
                c += '0'
            if a[0] == 'one':
                c += '1'
            if a[0] == 'two':
                c += '2'
            if a[0] == 'three':
                c += '3'
            if a[0] == 'four':
                c += '4'
            if a[0] == 'five':
                c += '5'
            if a[0] == 'six':
                c += '6'
            if a[0] == 'seven':
                c += '7'
            if a[0] == 'eight':
                c += '8'
            if a[0] == 'nine':
                c += '9'
            
            if a[1] == 'zero':
                c += '0'
            if a[1] == 'one':
                c += '1'
            if a[1] == 'two':
                c += '2'
            if a[1] == 'three':
                c += '3'
            if a[1] == 'four':
                c += '4'
            if a[1] == 'five':
                c += '5'
            if a[1] == 'six':
                c += '6'
            if a[1] == 'seven':
                c += '7'
            if a[1] == 'eight':
                c += '8'
            if a[1] == 'nine':
                c += '9'
            
            if a[2] == 'zero':
                c += '0'
            if a[2] == 'one':
                c += '1'
            if a[2] == 'two':
                c += '2'
            if a[2] == 'three':
                c += '3'
            if a[2] == 'four':
                c += '4'
            if a[2] == 'five':
                c += '5'
            if a[2] == 'six':
                c += '6'
            if a[2] == 'seven':
                c += '7'
            if a[2] == 'eight':
                c += '8'
            if a[2] == 'nine':
                c += '9'

            c = int(c)
            c2 = c

            d1 = 0
            d2 = 0
            e = False
            while e != True:
                e = prost(c)
                if e == True:
                    e = e
                    d1 = d1
                    c = c
                else:
                    d1 += 1
                    c -= 1
            e = False
            while e != True:
                e = prost(c2)
                if e == True:
                    e = e
                    d2 = d2
                    c2 = c2
                else:
                    d2 += 1
                    c2 += 1

            if d1 > d2:
                print(c2)
            if d2 > d1:
                print(c)
            else:
                print(c)
        else:
            print('wrong input')
    else:
        print('wrong input')
else:
    print('wrong input')
